#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;
    if (n < 1 || n > 10000) {
        return 0;
    }
    
    int listA1[n],listB1[n]; // 左下角坐标
    int listA2[n],listB2[n]; // 右上角坐标
    for (int i = 1; i <= n; i++)
    {
        int a,b,g,k;
        cin >> a >> b >> g >> k;
        listA1[i] = a;
        listA2[i] = a + g;
        listB1[i] = b;
        listB2[i] = b + k;
    }

    int x,y;
    cin >> x >> y;
    int res = 0; // x,y点在哪个地毯上
    for (int i = n; i >= 1; i--)
    {
        if (res == 0 && x >= listA1[i] && x <= listA2[i] && y >= listB1[i] && y <= listB2[i])
        {
            res = i;
            cout << res;
            return 0;
        }
    }
    cout << -1;
    
    return 0;
}